<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>深拷贝</h2>
</body>
<script>
    //1.对象深拷贝
    let obj = {
        name: 'alice',
       // un:undefined,
       // test:null,
      //  fn:function() {},
        age: 20,
        address:{
            ad1:'地址1',
            ad2:'地址2',
        }
    }

  // console.log('转换为对象：',JSON.parse(JSON.stringify(obj)))

  let obj2=JSON.parse(JSON.stringify(obj))


    obj.name='张三丰'
    obj.address.ad1='河南'

    console.log('obj',obj)
    console.log('obj2',obj2)




  //2.数组深拷贝
 // let arr=[11,22,33,'hello','vue',['aaa','bbb']]

   



</script>

</html>